<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itcast" uri="http://itcast.cn/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="author" content="" />

<title>修改卷筒分切明细表</title>
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet"
	media="screen" />
<link href="<%=basePath%>css/bootstrap-datetimepicker.min.css"
	rel="stylesheet" media="screen" />
<!-- Bootstrap Core CSS -->
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />

<!-- MetisMenu CSS -->
<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />

<!-- DataTables CSS -->
<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />

<!-- Custom CSS -->
<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />

<!-- Custom Fonts -->
<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet"
	type="text/css" />
<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet"
	type="text/css" />

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

	<div id="wrapper">


		<!-- Navigation -->
		<nav class="navbar navbar-default navbar-static-top" role="navigation"
			style="margin-bottom: 0">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target=".navbar-collapse">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="navbar-brand" href="<%=basePath%>index.action">工单管理系统V1.0</a>
			<div class="navbar-brand">欢迎您：${sessionScope.user_login.username}</div>
		</div>
		<!-- /.navbar-header --> <!-- /.navbar-top-links -->

		<div class="navbar-default sidebar panel-collapse collapse in"
			role="navigation">
			<div class="sidebar-nav navbar-collapse">
				<ul class="nav" id="side-menu">
					<li><a href="#WorkOrderSetting"
						class="sidebar-nav navbar-collapse" data-toggle="collapse">&nbsp;&nbsp;
							<i class="fa fa-th-list fa-fw"></i> 工单管理
					</a></li>
					<ul id="WorkOrderSetting" class="nav nav-list collapse secondmenu">
						<!-- <li><a href="<%=basePath%>createWorkOrder.action">&nbsp;&nbsp;<i class="fa fa-edit fa-fw"></i> 新建工单</a></li> -->
						<li><a href="<%=basePath%>queryWorkOrder.action">&nbsp;&nbsp;<i
								class="fa fa-eye fa-fw"></i> 查询工单
						</a></li>
						<li><a href="<%=basePath%>addMissionOrder.action">&nbsp;&nbsp;<i
								class="fa fa-plus fa-fw"></i> 新建任务
						</a></li>
						<li><a href="<%=basePath%>queryMissionOrder.action">&nbsp;&nbsp;<i
								class="fa fa-folder-open fa-fw"></i> 查询任务
						</a></li>
						<li><a href="<%=basePath%>statistics.action">&nbsp;&nbsp;<i class="fa fa-line-chart fa-fw"></i> 统计数据</a></li>
					</ul>
					<li><a href="#customerSetting"
						class="sidebar-nav navbar-collapse" data-toggle="collapse">&nbsp;&nbsp;
							<i class="fa fa-user fa-fw"></i> 员工管理
					</a></li>
					<ul id="customerSetting" class="nav nav-list collapse secondmenu">
						<li><a href="<%=basePath%>register.action">&nbsp;&nbsp;<i
								class="fa fa-plus fa-fw"></i> 创建员工
						</a></li>
						<li><a href="<%=basePath%>queryUser.action">&nbsp;&nbsp;<i
								class="fa fa-edit fa-fw"></i> 查询员工
						</a></li>
						<!-- <li><a href="#">&nbsp;&nbsp;<i class="fa fa-edit fa-fw"></i> 密码修改</a></li> -->
					</ul>
					<li><a href="#quit" class="sidebar-nav navbar-collapse"
						data-toggle="collapse">&nbsp;&nbsp;&nbsp;<i
							class="fa fa-remove fa-fw"></i> 账号登出
					</a></li>
					<ul id="quit" class="nav nav-list collapse secondmenu">
						<li><a href="<%=basePath%>quit.action">&nbsp;&nbsp;<i
								class="fa fa-remove fa-fw"></i> 退出
						</a></li>
					</ul>

				</ul>
			</div>
			<!-- /.sidebar-collapse -->
		</div>
		<!-- /.navbar-static-side --> </nav>

		<div id="page-wrapper">
			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">修改卷筒分切明细表</h1>
				</div>
				<!-- /.col-lg-12 -->
			</div>

			<div class="container">
				<form id="updateworkorderform" class="form-horizontal"
					action="${pageContext.request.contextPath }/createWorkOrder.action"
					method="post" style="margin-top: 5px;">
					<div class="row">
						<input type="hidden" id="m_date" name="m_date"
							value="${w_order.m_date}" /> <input type="hidden" id="m_time"
							name="m_time" value="${w_order.m_time}" /> <input type="hidden"
							id="w_time" name="w_time" value="${w_order.w_time}" /> <input
							type="hidden" id="bak_worktotalcount" name="bak_worktotalcount"
							value="${w_order.good_count}" />
						<div class="form-group col-lg-12">
							<h4>任务部分：</h4>
						</div>
						<div class="form-group col-lg-6">
							<label for="m_id" class="col-sm-2 control-label">任务单号</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="m_id" name="m_id" placeholder="任务单号"
									value="${m_order.m_id }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="m_user" class="col-sm-2 control-label">下单人员</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="m_user" name="m_user"
									placeholder="下单人员" value="${m_order.m_user }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="m_count" class="col-sm-2 control-label">任务张数(件)</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="m_count" name="m_count"
									placeholder="任务张数" value="${m_order.m_count }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="m_num" class="col-sm-2 control-label">任务件数(张)</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="m_num" name="m_num" placeholder="任务件数"
									value="${m_order.m_num }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="m_weight" class="col-sm-2 control-label">任务重量(kg)</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="m_weight" name="m_weight"
									placeholder="任务重量" value="${m_order.m_weight}" />
							</div>
						</div>

						<div class="form-group col-lg-6">
							<label for="worktotalcount" class="col-sm-2 control-label">完成张数(张)</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="worktotalcount" name="worktotalcount"
									placeholder="已完成张数" value="${m_order.worktotalcount}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="isfinish" class="col-sm-2 control-label">是否完成</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="isfinish" name="isfinish"
									placeholder="是否完成" value="${m_order.isfinish}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="child_count" class="col-sm-2 control-label">子单数量</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="child_count" name="child_count"
									placeholder="任务表下有多少个分切明细表" value="${m_order.child_count}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="m_remark" class="col-sm-2 control-label">任务备注</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="m_remark" name="m_remark"
									placeholder="备注" value="${m_order.m_remark}" />
							</div>
						</div>
						<div class="form-group col-lg-12">
							<hr>
						</div>
						<div class="form-group col-lg-12">
							<h4>卷筒部分：</h4>
						</div>
						<div class="form-group col-lg-6">
							<label for="w_id" class="col-sm-2 control-label">明细表单号</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="w_id" name="w_id" placeholder="明细表单号"
									value="${w_order.w_id }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="w_date" class="col-sm-2 control-label">分切日期&nbsp;&nbsp;</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="w_date" name="w_date"
									placeholder="分切日期" value="${w_order.w_date }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="w_user" class="col-sm-2 control-label">分切人员</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="w_user" name="w_user"
									placeholder="分切人员" value="${w_order.w_user }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="gname" class="col-sm-2 control-label">商品名称</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="gname" name="gname"
									placeholder="请输入商品名称" value="${m_order.gname}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="grammage" class="col-sm-2 control-label">卷筒克重(克/平米)</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="grammage" name="grammage"
									placeholder="请输入克重" value="${m_order.grammage}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="wide" class="col-sm-2 control-label">卷筒宽幅(毫米)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="wide"
									value="${w_order.wide }" name="wide" placeholder="请输入宽幅" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="w_weight" class="col-sm-2 control-label">卷筒重量(kg)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="w_weight"
									name="w_weight" placeholder="请输入重量"
									value="${w_order.w_weight }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="length" class="col-sm-2 control-label">卷筒长度(米)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="length"
									name="length" placeholder="请输入长度" value="${w_order.length }" />
							</div>
						</div>

						<div class="form-group col-lg-12">
							<hr>
						</div>
						<div class="form-group col-lg-12">
							<h4>成品部分：</h4>
						</div>
						<div class="form-group col-lg-6">
							<label for="pname" class="col-sm-2 control-label">成品名称</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="pname" name="pname" placeholder="成品名称"
									value="${m_order.pname }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="address" class="col-sm-2 control-label">送货地址</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="address" name="address"
									placeholder="送货地址" value="${m_order.address }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="specification" class="col-sm-2 control-label">平板规格(mm*mm)</label>
							<div class="col-sm-8">
								<input type="text" readonly unselectable="on"
									class="form-control" id="specification" name="specification"
									placeholder="平板规格" value="${m_order.specification }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="good_count" class="col-sm-2 control-label">成品张数(张)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="good_count"
									onFocus="getGood_count()" name="good_count"
									placeholder="请输入成品数量" value="${w_order.good_count}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="good_weight" class="col-sm-2 control-label">成品重量(kg)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="good_weight"
									onFocus="getGood_weight()" name="good_weight"
									placeholder="请输入成品重量" value="${w_order.good_weight }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="defective_count" class="col-sm-2 control-label">次品张数(张)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="defective_count"
									onFocus="getDefective_count()" name="defective_count"
									placeholder="请输入次品数量" value="${w_order.defective_count}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="defective_weight" class="col-sm-2 control-label">次品重量(kg)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="defective_weight"
									onFocus="getDefective_weight()" name="defective_weight"
									placeholder="请输入次品重量" value="${w_order.defective_weight }" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="total_weight" class="col-sm-2 control-label">总重量(kg)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="total_weight"
									onFocus="getTotal_weight()" name="total_weight"
									placeholder="请输入总重量" value="${w_order.total_weight}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="surplus_weight" class="col-sm-2 control-label">原料结余(kg)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="surplus_weight"
									onFocus="getSurplus_weight()" name="surplus_weight"
									placeholder="请输入原料结余" value="${w_order.surplus_weight}" />
							</div>
						</div>

						<div class="form-group col-lg-6">
							<label for="true_weight" class="col-sm-2 control-label">实用总量(kg)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="true_weight"
									onFocus="getTrue_weight()" name="true_weight"
									placeholder="请输入实用总量" value="${w_order.true_weight}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="deviation" class="col-sm-2 control-label">误差重量(kg)</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="deviation"
									onFocus="getDeviation()" name="deviation" placeholder="请输入误差总量"
									value="${w_order.deviation}" />
							</div>
						</div>
						<div class="form-group col-lg-6">
							<label for="w_remark" class="col-sm-2 control-label">员工备注</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" id="w_remark"
									name="w_remark" placeholder="请输入备注"
									value="${w_order.w_remark }" />
							</div>
						</div>
						<c:if test="${sessionScope.user_login.role=='manager'}">
						<div class="form-group col-lg-6">
							<label for="audit" class="col-sm-2 control-label">审核状态</label>
							<div class="col-sm-8">
								<select class="form-control" id="audit" name="audit">
									<option value="no"
										<c:if test="${w_order.audit=='no'}"> selected</c:if>>未审核</option>
									<option value="yes"
										<c:if test="${w_order.audit=='yes'}"> selected</c:if>>已审核</option>
								</select>
							</div>
						</div>
						</c:if>
						<c:if test="${sessionScope.user_login.role=='employee'}">
							<input type="hidden" id="audit" name="audit" value="${w_order.audit}" />
						</c:if>
						<div class="form-group col-lg-12">
							<hr>
						</div>

						<div class="form-group" align="center">
							<div class="col-sm-12">
								<button type="button" class="btn btn-primary"
									onclick="updateWorkOrder()">保存修改</button>
								<button type="button" class="btn btn-danger"
									onclick="history.go(-1)">取消</button>
							</div>
						</div>
					</div>
				</form>
			</div>
			<div>
				<div class="hidden-sm hidden-xs" style="height: 160px;">&nbsp;</div>
			</div>

		</div>
	</div>


	<!-- jQuery -->
	<script src="<%=basePath%>js/jquery.min.js"></script>

	<!-- Bootstrap Core JavaScript -->
	<script src="<%=basePath%>js/bootstrap.min.js"></script>

	<!-- Metis Menu Plugin JavaScript -->
	<script src="<%=basePath%>js/metisMenu.min.js"></script>

	<!-- DataTables JavaScript -->
	<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
	<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>

	<!-- Custom Theme JavaScript -->
	<script src="<%=basePath%>js/sb-admin-2.js"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/jquery-1.8.3.min.js" charset="UTF-8"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/locales/bootstrap-datetimepicker.zh-CN.js"
		charset="UTF-8"></script>
	<script type="text/javascript"
		src="<%=basePath%>js/locales/bootstrap-datetimepicker.fr.js"
		charset="UTF-8"></script>
	<script type="text/javascript">
		$('.form_date').datetimepicker({
			language : 'zh-CN',
			weekStart : 1,
			todayBtn : 1,
			autoclose : 1,
			todayHighlight : 1,
			startView : 2,
			minView : 2,
			forceParse : 0
		});
		$('.form_date').datetimepicker({
			format : "dd MM yyyy",
			linkField : "dtp_input2",
			linkFormat : "yyyy-mm-dd"
		});
		
		function getDeviation(){
			var total_weight = $("#total_weight").val();
			var true_weight = $("#true_weight").val();
			var deviation_math = Number(true_weight)-Number(total_weight);
			$("#deviation").val(deviation_math);
		}
		function getTrue_weight(){
			var w_weight = $("#w_weight").val();
			var surplus_weight = $("#surplus_weight").val();
			var true_weight_math = Number(w_weight)-Number(surplus_weight);
			$("#true_weight").val(true_weight_math);
		}
		function getTotal_weight(){
			var good_weight = $("#good_weight").val();
			var defective_weight = $("#defective_weight").val();
			var total_weight_math = Number(good_weight)+Number(defective_weight);
			$("#total_weight").val(total_weight_math);
		}
		function getDefective_weight(){
			var specification = $("#specification").val().split('*');
			var grammage = $("#grammage").val()/1000;
			var defective_count = $("#defective_count").val();
			var defective_weight_math = Number(grammage)*Number(defective_count)*Number(specification[0])*Number(specification[1])/1000000;
			$("#defective_weight").val(defective_weight_math);
		}
		function getGood_weight(){
			var specification = $("#specification").val().split('*');
			var grammage = $("#grammage").val()/1000;
			var good_count = $("#good_count").val();
			var good_weight_math = Number(grammage)*Number(good_count)*Number(specification[0])*Number(specification[1])/1000000;
			$("#good_weight").val(good_weight_math);
		}
		function updateWorkOrder(){
			/* var grammage = $("#grammage").val();
			var gname = $("#gname").val();*/
			
			$.ajax({
				type:"post",
				url:"<%=basePath%>updateWorkOrder.action",
				data : $('#updateworkorderform').serialize(),
				success : function(data) {
					if (data.trim() == "ok") {
						alert("保存成功 ");
					}
					if (data.trim() == "forbid") {
						alert("此单已经审核，禁止修改！");
					}
					if (data.trim() == "no") {
						alert("保存失败 ");
					}
				},
				error : function() {
					alert("保存失败 ");
				}
			});
		}
	</script>

</body>

</html>
